
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using Ezio.Model;

//Service Route: Copy to 'Global.asax'
//  RouteTable.Routes.Add(new ServiceRoute("ItemsCompromisos", new WebServiceHostFactory(), typeof(ItemsCompromisosService)));
//
namespace Ezio.Service
{
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    [XmlSerializerFormat]
    public class ItemsCompromisosService : BaseService
    {

        [WebInvoke(UriTemplate = "", Method = "POST")]
        public bool Create(ItemsCompromisos ItemCompromio)
        {
            Provider.AddToItemsCompromisos(ItemCompromio);
            return Provider.TrySaveChanges();
        }

        [WebInvoke(UriTemplate = "", Method = "PUT")]
        public bool Update(ItemsCompromisos ItemCompromiso)
        {
            ItemsCompromisos miItemCompromio = Provider.ItemsCompromisos.Where(t => t.IdItemCompromiso == ItemCompromiso.IdItemCompromiso).First();
            miItemCompromio.Copy(ItemCompromiso);
            return Provider.TrySaveChanges();
        }

        [WebInvoke(UriTemplate = "{IdItemCompromio}", Method = "DELETE")]
        public bool Delete(string IdItemCompromiso)
        {
            int Id = int.Parse(IdItemCompromiso);
            Provider.ItemsCompromisos.DeleteObject(Provider.ItemsCompromisos.Where(t => t.IdItemCompromiso == Id).First());
            return Provider.TrySaveChanges();
        }

    }
}